// 主界面
;define(function(require, exports, module) {
    'use strict';
    var util = require("util");
    var base = require(CONFIG.BasePath + "js/enterprise/base");
    var router = require("../hash/pageRouter");
    var footer = require("../footer/footer_gray");
    var top = require("../top/top_white");
    var validate = require("validate");
    var retrievePasswordUuid;
    var css_setPassword = require("./retrieve_setPsw.css");
    var mobile;
    var authenticode;
    var password;
    var re_password;
    var wait = 60;
    var flag = false;
    var init = function(page){
    	retrievePasswordUuid = page.params.retrievePasswordUuid;
    	mobile = page.params.mobile;
    	authenticode = page.params.authenticode;
    	router.init();
		initEvent(); 
    };
    
	var initEvent = function(){
		
		$("#setPswCommit").unbind("click").click(function(){
			password = $("#psw").val();
			re_password = $("#rePsw").val();
			
			if(password==null||password.length<=0){
				$(".errinfo3").html("请输入密码！");
				$(".errinfo3").removeClass("none");
				flag = false;
			}else if(re_password==null||re_password.length<=0){
				$(".errinfo3").html("请确认密码！");
				$(".errinfo3").removeClass("none");
				flag = false;
			}else if(password!=re_password){
				$(".errinfo3").html("两次输入的密码不相同！");
				$(".errinfo3").removeClass("none");
				flag = false;
			}else{
				$(".errinfo3").addClass("none");
				flag = true
			}
			
			if(flag){
				retrieve();
			}
		});
    };
    

	 //找回密码
    var retrieve = function() {
    	base.fnAjax({
            action: "retrieveEnterpriseResetPasswordUuid.json",
            nocode: true,
            oData: {
                mobile: mobile,
                retrievePasswordUuid: retrievePasswordUuid,
                authenticode: authenticode,
                password: password
            }, //传递参数
            fnSuccess: function(data) {
                if (data.status == 200) {
                	router.route("retrievePassword/retrieve_success.html")
                } else {
                	$("#errinfo3").removeClass("none");
					$("#errinfo3").html(data.message);
					flag = false;
                }
            }
        });
    }

    return {
        init:init
    };
});